<?php

use yii\helpers\Html;
use yii\grid\GridView;


$this->title = Yii::t('app', 'Incomes');
$this->params['breadcrumbs'][] = $this->title;
?>

<style type="text/css">
    .cs1{margin:2px 5px;} 
</style>


<div class="income-index">

   <div class="box">
        <div class="box-header">
            <?= Html::a(Yii::t('app', 'Create Income'), ['create'], ['class' => 'btn btn-success']) ?>
        </div>
        <div class="box-body">
            <p>
                 <?php echo $this->render('_search', ['model' => $searchModel]); ?>
            </p>
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'layout'  =>  "{items}\n{summary}\n{pager}",
                'options' => [
                        'style'=>'overflow: auto; word-wrap: break-word;'
                ],
                'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],
                    [
                        'attribute' => 'code',
                        'headerOptions' => ['width' => '10%'],
                    ],
                    [
                        'attribute' => 'company',
                        'headerOptions' => ['width' => '10%'],
                    ],
                    [
                        'attribute' => 'currency',
                        'headerOptions' => ['width' => '5%'],
                        'value' => function ($model) {
                                return isset(Yii::$app->params['currency_type'][$model->currency])?Yii::$app->params['currency_type'][$model->currency]:'';
                            },
                    ],
                    [
                        'attribute' => 'price',
                        'headerOptions' => ['width' => '5%'],
                    ],
                    [
                        'attribute' => 'real_price',
                        'headerOptions' => ['width' => '5%'],
                    ],
                    [
                        'attribute' => 'pro_price',
                        'headerOptions' => ['width' => '5%'],
                    ],
                    [
                        'attribute' => 'rate',
                        'headerOptions' => ['width' => '5%'],
                    ],
                    [
                        'attribute' => 'status',
                        'headerOptions' => ['width' => '5%'],
                        'value' => function ($model) {
                                return isset(Yii::$app->params['status'][$model->status])?Yii::$app->params['status'][$model->status]:'';
                            },
                    ],
                    [
                        'attribute' => 'remark',
                        'headerOptions' => ['width' => '15%'],
                    ],
                     [
                          'label' =>  Yii::t('app', 'Confirmation Amount'),
                          'format'=>'raw',
                          'headerOptions' => ['width' => '5%'],
                          'value' => function($model){

                                return $model->claimPrice;
                          }
                    ],
                    [
                          'label' => Yii::t('app', 'Confirmation Status'),
                          'format'=>'raw',
                          'headerOptions' => ['width' => '10%'],
                          'value' => function($model){

                                return $model->isClaim;
                          }
                    ],
                    [
                          'attribute' => 'user_id',
                          'headerOptions' => ['width' => '5%'],
                          'value' => function($model){

                                return isset($model->user) ? $model->user->name : '管理员';
                          }
                    ],

                    [
                        'label'=>'操作',
                        'format'=>'raw',
                        'headerOptions' => ['width' => '15%'],
                        'value' => function($model){

                            $url  = sprintf("/income/income/view?id=%d", $model->id); //查看
                            $url2  = sprintf("/income/income/update?id=%d", $model->id); //更新
                            $url3  = sprintf("/income/claim/index?income_id=%d", $model->id); //收入认领

                            $str  = Html::a('查看',$url,['title' =>'查看','class'=>'btn btn-primary btn-xs cs1',]);
                            $str  .= Html::a('更新',$url2,['title' =>'更新','class'=>'btn btn-success btn-xs cs1',]);
                            $str .= Html::a('收入认领',$url3,['title' =>'收入认领','class'=>'btn btn-danger btn-xs cs1','target'=>'_blank']);
                            
                            return $str;
                         }
                    ],
                ],
            ]); ?>

        </div>

    </div>
            
</div>
